<template>
<view>
<form @submit="formSubmit">
<view class="set-mes">          
        <view class="invoice-remarks" :style="'display:' + (invoiceToggle?'none':'flex')">
            <view class>快递公司 : </view>                 
             <input type="text" name="express_name" placeholder></input>                   
        </view>
        <view class="invoice-remarks">
            <view class>快递用费 : </view> <input type="text" name="express_fee" placeholder></input>
        </view>
        <view class="invoice-remarks">
            <view class>快递单号: </view> <input type="text" name="express_sn" placeholder></input>
        </view>
         <view class="invoice-remarks">          
            <view class>发货时间 : </view>  
            <picker mode="date" :value="date" start="2018-01-01" end="2030-01-01" @change="bindDateChange">
            <view class="picker">
            <input type="text" name="express_time" disabled :value="date"></input>   
  </view>
  </picker>             
        </view>    
           <view class="invoice-remarks">
            <view class="invoice-text">温馨提示：购买15日内商品因质量问题、包装损坏、缺少附件等原因办理退换货产生的运费，以余额的方式补偿                </view> 
        </view>                           
    </view>
    <button class="use-btn" form-type="submit">确定</button>
</form>
</view>
</template>

<script>
// pages/cart/invoice/invoice.js
var app = getApp();
var request = app.globalData.request;
var common = require("../../../utils/common.js");

export default {
  data() {
    return {
      id: '',
      back_logistics: false,
      date: ""
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: options.id
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    formSubmit: function (e) {
      var that = this;
      var express_fee = e.detail.value.express_fee;
      var express_name = e.detail.value.express_name;
      var express_sn = e.detail.value.express_sn;
      var express_time = e.detail.value.express_time;

      if (!express_name) {
        app.globalData.confirmBox('请输入快递公司名称');
        return false;
      }

      if (!express_fee) {
        app.globalData.confirmBox('请输入快递费用');
        return false;
      }

      if (!express_sn) {
        app.globalData.confirmBox('请输入快递单号');
        return false;
      }

      if (!express_time) {
        app.globalData.confirmBox('请输入发货时间');
        return false;
      }

      var postData = {
        express_fee: express_fee,
        express_name: express_name,
        express_sn: express_sn,
        express_time: express_time,
        id: that.id
      };
      request.post('/api/order/checkReturnInfo', {
        data: postData,
        success: function (res) {
          let pages = getCurrentPages(); //当前页面

          let prevPage = pages[pages.length - 2]; //上一页面
          //直接给上移页面赋值 

          prevPage.setData({
            back_logistics: true
          });
          uni.navigateBack({
            delta: 1
          });
        }
      });
    },
    bindDateChange: function (e) {
      this.setData({
        date: e.detail.value
      });
    }
  }
};
</script>
<style>
/* pages/cart/invoice/invoice.wxss */
.set-mes{
    background-color: #fff;
    padding: 0 20rpx;
    font-size: 30rpx;
    color: #444;
}
.set-mes>view{
    display: flex;
    align-items: center;
    height: 92rpx;
    border-bottom: 1px solid #f5f5f5;
}
.set-mes input{
    width: 380rpx;
    height: 50rpx;
    line-height: 50rpx;
    border:1px solid #ddd;
}
.set-btn{
    display: flex;
    font-size: 24rpx;
}
.arrow-rigth{
    width: 32rpx;
    height: 32rpx; 
}
.invoice-text{
    color:red;font-size:12px;
}
.use-btn{
    height: 80rpx;
    margin-left: 20rpx;
    text-align: center;
    background-color: #ff6a00;
    color: #fff;
    font-size:16px;
}
</style>